package cn.gson.boot.model.service;

import cn.gson.boot.model.dao.JiaoFuJiLuLuLuDao;
import cn.gson.boot.model.dao.JiaoFuJiLuLuLuXiangQingDao;
import cn.gson.boot.model.mapper.JiaoFuJiLuLuLuMapper;
import cn.gson.boot.model.mapper.JiaoFuJiLuLuLuXiangQingMapper;
import cn.gson.boot.model.pojos.Jiaofujilu;
import cn.gson.boot.model.pojos.Jiaofujluxiangqing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class JiaoFuJiLuLuLuService {
    @Autowired
    JiaoFuJiLuLuLuMapper jiaoFuJiLuLuLuMapperu;
    @Autowired
    JiaoFuJiLuLuLuDao jiaoFuJiLuLuLuDao;
    @Autowired
    JiaoFuJiLuLuLuXiangQingDao jiaoFuJiLuLuLuXiangQingDao;
    @Autowired
    JiaoFuJiLuLuLuXiangQingMapper jiaoFuJiLuLuLuXiangQingMapper;

    //查询所有交付记录
    public List<Jiaofujilu> selectAllJiaoFuJiLuLuLu(String ddHao,String khName,String time){
        return jiaoFuJiLuLuLuMapperu.selectAllJiaoFuJiLuLuLu(ddHao,khName,time);
    }

    /*//新增交付记录
    public void addJiaoFuJiLu(Jiaofujilu jiaofujilu) {
        jiaofujilu.setJlYs(1);
        jiaoFuJiLuLuLuDao.save(jiaofujilu);
        Jiaofujluxiangqing dx = null;
        for (int i=0;i<jiaofujilu.jfJiHuaXiangQingList.size();i++) {
            dx = new Jiaofujluxiangqing();

            dx.setProduct(jiaofujilu.jfJiHuaXiangQingList.get(i).getProduct());
            dx.setJfjlxqCpnum(jiaofujilu.jfJiHuaXiangQingList.get(i).getJfjhxqNum());
            dx.setJfjlxqCpprice(jiaofujilu.jfJiHuaXiangQingList.get(i).getJfjhxqPrice());
            dx.setJiaofujiluByJlId(jiaofujilu);
            dx.setJfjlxqXiaoJi(jiaofujilu.jfJiHuaXiangQingList.get(i).getJfjhXiaoJi());

            jiaoFuJiLuLuLuXiangQingDao.save(dx);
        }
    }*/

    //根据记录id查找交录详情
    public List<Jiaofujluxiangqing> selectJLXQbyjjId(Integer jlId) {
        return jiaoFuJiLuLuLuXiangQingMapper.selectJLXQbyjjId(jlId);
    }

    //移除交付记录
    public void yichuJiaoFuJiLu(Integer jlId) {
        jiaoFuJiLuLuLuDao.yichuJiaoFuJiLu(jlId);
    }
}